﻿using System;
using CxRomos.Core.Services;
using CxRomos.Core.Services.Implementation;
using StructureMap;

namespace CxRomos.Web {
    public class Global : System.Web.HttpApplication {

        protected void Application_Start(object sender, EventArgs e) {
            ObjectFactory.Initialize(rep => rep.UseDefaultStructureMapConfigFile = true);
            Log.EnsureInitialized();
        }

        protected void Session_Start(object sender, EventArgs e) {

        }

        protected void Application_BeginRequest(object sender, EventArgs e) {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e) {

        }

        protected void Application_Error(object sender, EventArgs e) {
            Log.Error(sender, "Error caught by the Global.asax: " + e.ToString());

            var redirector = ObjectFactory.GetInstance<IRedirector>();
            //redirector.GoToErrorPage();
        }

        protected void Session_End(object sender, EventArgs e) {

        }

        protected void Application_End(object sender, EventArgs e) {

        }
    }
}